<?php

namespace App\Http\Requests\airline\base;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait ContainerRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'code_id' => 'required|numeric',
            'vehicle' => 'required|numeric',
            'container_id' => 'required',
        ], [
            'code_id.required' => '请选择CODE',
            'vehicle.required' => '请选择载具',
            'container_id.required' => '请填写集装器id',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
